
#include "gamewindow.h"
#include "gameboard.h"
#include <QAction>
#include <QMessageBox>
#include <QMenu>
#include <QMenuBar>
#include <QDebug>
#include <QLabel>

GameWindow::GameWindow(unsigned n) : QMainWindow(0)
{
    actionExit = new QAction(tr("Exit(&x)"), this);
    actionExit->setObjectName("actionExit");
    actionUndo = new QAction(tr("Undo(&u)"), this);
    actionUndo->setObjectName("actionUndo");
    QMenu* menuFile = menuBar()->addMenu(tr("&File"));
    menuFile->addAction(actionUndo);
    menuFile->addSeparator();
    menuFile->addAction(actionExit);
    
    actionHumenFirst = new QAction(tr("Humen First"), this);
    actionHumenFirst->setObjectName("actionHumenFirst");
    actionRobotFirst = new QAction(tr("Robot First"), this);
    actionRobotFirst->setObjectName("actionRobotFirst");
    
    QMenu * menuRestart = menuBar()->addMenu(tr("&Restart"));
    menuRestart->addAction(actionHumenFirst);
    menuRestart->addAction(actionRobotFirst);
    
    
    _board = new GameBoard(this);
    _board->setObjectName("board");
    setCentralWidget(_board);

    QMetaObject::connectSlotsByName(this);
    qDebug() << "end";
}

void GameWindow::on_actionExit_triggered()
{
    int ret = QMessageBox::warning(this, tr("Confirm"),
                    tr("Application is going to exit.\n"
                    "Do you really want to exit?"),
                    QMessageBox::Yes | QMessageBox::No
                    | QMessageBox::Cancel, QMessageBox::No);
    if (ret == QMessageBox::Yes)
        this->close();
}

void GameWindow::on_actionUndo_triggered()
{
    _board->undo();
}

void GameWindow::on_actionHumenFirst_triggered()
{
    _board->restart(true);
}

void GameWindow::on_actionRobotFirst_triggered()
{
    _board->restart(false);
}

//#include "gamewindow.moc"

